﻿using BMS.Visitor.BL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BMS.Visitor.DL
{
    public class VisitorDataLogic : IDataLogic<BMS.Visitor.Model.Entities.Visitor>
    {
        IBusinessLogic<BMS.Visitor.Model.Entities.Visitor> visitor;

        public void Save(BMS.Visitor.Model.Entities.Visitor persistenceObject)
        {
            visitor = new VisitorBusinessLogic();

            if (string.IsNullOrEmpty(persistenceObject.DocumentId))
            {
                throw new Exception("El documento de identficación es obligatorio");
            }
            if (string.IsNullOrEmpty(persistenceObject.Name))
            {
                throw new Exception("El nombre es obligatorio");
            }
            if (string.IsNullOrEmpty(persistenceObject.LastName))
            {
                throw new Exception("El apellido es obligatorio");
            }
            //if (string.IsNullOrEmpty(persistenceObject.FingerPrint))
            //{
            //    throw new Exception("La huella es obligatoria");
            //}
            visitor.Save(persistenceObject);
        }

        public List<BMS.Visitor.Model.Entities.Visitor> List()
        {
            visitor = new VisitorBusinessLogic();
            return visitor.List();
        }
    }
}
